
package com.feib.soeasy.job;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.feib.soeasy.job.service.ForceLogoutService;


/**
 * @title (#)ForceLogoutJob.java<br>
 * @description 強迫登出批次<br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2010/12/16 create by Jimmy Liu<br>
 */
@Service("forceLogoutJob")
public class ForceLogoutJob implements Serializable {

    private static final long serialVersionUID = -22786292182545699L;

    public static Logger logger = LoggerFactory.getLogger(ForceLogoutJob.class);
    
    private static Integer DEFAULT_MINITUES = new Integer(-9); 

    @Resource(name="forceLogoutService")
    private ForceLogoutService forceLogoutService;
    
    public void execute(Integer minitue)
    {
        try {
            if (null == minitue)
                minitue = DEFAULT_MINITUES;
            
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.MINUTE, minitue);
            Date date = cal.getTime();            
            forceLogoutService.logout(date);            
        }
        catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }

}
